package com.project.user.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.project.user.mapper.UserGoodsPreferMapper;
import com.project.user.domain.UserGoodsPrefer;
import com.project.user.service.IUserGoodsPreferService;

/**
 * 用户收藏餐饮关联 服务层实现
 *
 * @author administrator
 */
@Service
public class UserGoodsPreferServiceImpl implements IUserGoodsPreferService {
    @Autowired
    private UserGoodsPreferMapper userGoodsPreferMapper;

    /**
     * 查询用户收藏餐饮关联信息
     *
     * @param userGoodsPrefer 用户收藏餐饮关联ID
     * @return 用户收藏餐饮关联信息
     */
    @Override
    public Integer countUserGoodsPrefer(UserGoodsPrefer userGoodsPrefer) {
        return userGoodsPreferMapper.countUserGoodsPrefer(userGoodsPrefer);
    }

    /**
     * 查询用户收藏餐饮关联列表
     *
     * @param userGoodsPrefer 用户收藏餐饮关联信息
     * @return 用户收藏餐饮关联集合
     */
    @Override
    public List<UserGoodsPrefer> selectUserGoodsPreferList(UserGoodsPrefer userGoodsPrefer) {
        return userGoodsPreferMapper.selectUserGoodsPreferList(userGoodsPrefer);
    }

    /**
     * 新增用户收藏餐饮关联
     *
     * @param userGoodsPrefer 用户收藏餐饮关联信息
     * @return 结果
     */
    @Override
    public int insertUserGoodsPrefer(UserGoodsPrefer userGoodsPrefer) {
        if (userGoodsPreferMapper.countUserGoodsPrefer(userGoodsPrefer) > 0) {
            return 1;
        }
        return userGoodsPreferMapper.insertUserGoodsPrefer(userGoodsPrefer);
    }


    /**
     * 删除用户收藏餐饮关联对象
     *
     * @param userGoodsPrefer 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteUserGoodsPrefer(UserGoodsPrefer userGoodsPrefer) {
        return userGoodsPreferMapper.deleteUserGoodsPrefer(userGoodsPrefer);
    }

}
